<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                template="./../resources/TempAdmin.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="content">
        <link rel="stylesheet" type="text/css" href="../resources/css/style2.css" />
        <h:outputStylesheet library="css" name="tabela.css" />
        <h:outputStylesheet library="css" name="estilo.css" />
        <div class="header">
            Cadastro de Genero
        </div>
        <p:separator />
        <h:form id="frmGenero">
            <p:growl />
            <h:inputHidden value="#{generoBean.genero.codGenero}" />
            <h:panelGrid columns="2">
                <h:outputLabel for="genero" value="Genero.:" styleClass="lb" />
                <h:inputText id="genero" value="#{generoBean.genero.descricao}" styleClass="tx" size="50" onkeyup="this.value = this.value.toUpperCase()" required="true" requiredMessage="Genero Obrigatório" />
            </h:panelGrid>
            <h:panelGrid columns="2">
                <h:commandButton value="Cancelar" actionListener="#{generoBean.cancelar}" styleClass="btn" immediate="true">
                    <p:ajax update="@form :frmTable" />
                </h:commandButton>                    
                <h:commandButton value="Salvar" action="#{generoBean.salvarGenero}" styleClass="btn" />
            </h:panelGrid>
        </h:form>
        <h:form id="frmTable" rendered="#{generoBean.generos.size() > 0}">
            <h:dataTable value="#{generoBean.generos}" var="g" styleClass="tabela" headerClass="cabecalho" rowClasses="linA, linB"
                         columnClasses="f_codigo, c_titulo, f_op">
                <h:column>
                    <f:facet name="header">Código</f:facet>
                    <h:outputText value="#{g.codGenero}" />
                </h:column>
                <h:column>
                    <f:facet name="header">Descrição</f:facet>
                    <h:outputText value="#{g.descricao}" />
                </h:column>
                <h:column>
                    <f:facet name="header">Descrição</f:facet>
                    <p:commandLink value="Alterar" action="#{generoBean.editar(g.codGenero)}" ajax="false" update=":frmGenero" styleClass="links" />
                </h:column>
            </h:dataTable>
        </h:form>
    </ui:define> 
</ui:composition>
